package com.example.logisticsingle.Mapper;

import com.example.logisticsingle.model.SystemUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

@Mapper
public interface SystemUserMapper {
    /**
     * 根据用户名查找用户
     * @param username
     * @return
     */
    @Select("SELECT * FROM sys_user WHERE user_name = #{username}")
    @Results(id="user",value={
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "user_name", property = "userName"),
            @Result(column = "mobile_no", property = "mobileNo"),
            @Result(column = "last_login_ip", property = "lastLoginIp"),
            @Result(column = "last_login_time", property = "lastLoginTime"),
            @Result(column = "create_user_id", property = "createUserId"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_user_id", property = "updateUserId"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "dept_id", property = "deptId"),
            @Result(column = "platform_code", property = "platformCode"),
            @Result(column = "user_type", property = "userType")
    })
    SystemUser findUserByUsername(@Param("username") String username);
}
